#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
void Swap(int* p1, int* p2)
{
	int tem = *p1;
	*p1 = *p2;
	*p2 = tem;
}

int _QuickSort(int* a, int begin, int end)
{
	int keyi = begin;
	int prev = begin;
	int cur = prev + 1;
	while (cur <= end)
	{
		if (a[cur] < a[keyi] && prev++ != cur)
		{
			Swap(&a[cur], &a[prev]);
		}
		cur++;
	}
	keyi = prev;
	return keyi;
}

void QuickSort(int* a, int begin, int end)
{
	int left = begin;
	int right = end;
	if (left >= right)
		return;
	int keyi = _QuickSort(a, begin, end);
	QuickSort(a, begin, keyi - 1);
	QuickSort(a, keyi + 1, end);
}
int main()
{
	int a[] = { 4,4,2,14,6,7,8,9,0,23 };
	int len = sizeof(a) / sizeof(int);
	QuickSort(a, 0,len - 1);
	for (int i = 0; i < len; i++)
	{
		printf("%d ", a[i]);

	}
	printf("\n");
	return 0;
}